﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class Staff
    {

        public bool insert(Model.Staff mLKMT)
        {
            string sql = "insert into Staff (StaID, StaName,StaNumber) values(@StaID, @StaName,@StaNumber)";
            
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            sqlParams.Add(new SqlParameter("@StaID", mLKMT.StaID));
            sqlParams.Add(new SqlParameter("@StaName", mLKMT.StaName));
            sqlParams.Add(new SqlParameter("@StaNumber", mLKMT.StaNumber));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public bool update(Model.Staff mLKMT, string oldStaID)
        {
            string sql = "update Staff set StaID=@StaID, StaName= @StaName,StaNumber=@StaNumber where StaID=@oldStaID";
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            sqlParams.Add(new SqlParameter("@StaID", mLKMT.StaID));
            sqlParams.Add(new SqlParameter("@StaName", mLKMT.StaName));
            sqlParams.Add(new SqlParameter("@StaNumber", mLKMT.StaNumber));
            sqlParams.Add(new SqlParameter("@oldStaID", oldStaID));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public bool delete(string StaID)
        {
            string sql = "delete from Staff where StaID=@StaID";
            List<SqlParameter> sqlParams = new List<SqlParameter>();
            sqlParams.Add(new SqlParameter("@StaID", StaID));
            return DBUtitlity.DbHelperSQL.ExecuteSql(sql, sqlParams);
        }
        public DataTable select(string strWhere)
        {
            string sql = "select * from Staff";
            if (strWhere != "")
            {
                sql += " where " + strWhere;
            }
            return DBUtitlity.DbHelperSQL.Query(sql);
        }
    }
}
